﻿@{
    ViewData["Title"] = "添加PLC写入DB配置";
    Layout = "_Edit";
}
<article class="page-container">
    <form action="" method="post" class="form form-horizontal" id="form-add">
       @* <input type="hidden" class="input-text" value="@Model.EquipmentCode" id="id" name="id">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.EquipmentCode" placeholder="" id="EquipmentCode" name="EquipmentCode">
            </div>
        </div>*@
        <input type="hidden" class="input-text" value="@Model.ID" id="id" name="id">
        
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>DB编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.DbCode" placeholder="" id="DbCode" name="DbCode">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>DB读取起始位：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.DbStart" placeholder="" id="DbStart" name="DbStart">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>设备编号：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.EquipmentCode" placeholder="" id="EquipmentCode" name="EquipmentCode">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>写入类型：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="@Model.ObjectType" placeholder="" id="ObjectType" name="ObjectType">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>PLC连接IP：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <span class="select-box">
                    <select class="select" size="1" name="PlcConnectionId" id="PlcConnectionId">
                        <option value="0">--请选择--</option>
                        @foreach (var item in Model.PlcIpSearchs)
                        {
                            if (Model.PlcConnectionId + "" == item.PlcConnectId)
                            {
                                <option value="@item.PlcConnectId" selected>@item.PlcConnectIp</option>
                            }
                            else
                            {
                                <option value="@item.PlcConnectId">@item.PlcConnectIp</option>
                            }
                        }
                    </select>
                </span>
            </div>
        </div>
        
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <input class="btn btn-primary radius" type="button" onclick="operate()" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>
        </div>
    </form>
</article>

@section javascript{

<script>
    $('.skin-minimal input').iCheck({
         checkboxClass: 'icheckbox-blue',
         radioClass: 'iradio-blue',
         increaseArea: '20%'
     });
     function operate(){
         

          var EquipmentCode=$("#EquipmentCode").val();
         if(EquipmentCode==null||EquipmentCode=="")
         {
            popupAlert('请输入设备号',2,function(data){layer.close(data);});
           return;
         }

         var DbCode=$("#DbCode").val();
         if(DbCode==null||DbCode=="")
         {
            popupAlert('请输入DB编号',2,function(data){layer.close(data);});
           return;
         }
         
         var DbStart=$("#DbStart").val();
         if(DbStart==null||DbStart=="")
         {
            popupAlert('请输入DB读取起始位',2,function(data){layer.close(data);});
           return;
         }
         var EquipmentCode=$("#EquipmentCode").val();
         if(EquipmentCode==null||EquipmentCode=="")
         {
            popupAlert('请输入设备编号',2,function(data){layer.close(data);});
           return;
         }
         var ObjectType=$("#ObjectType").val();
         if(ObjectType==null||ObjectType=="")
         {
            popupAlert('请输入报文处理模块类型',2,function(data){layer.close(data);});
           return;
         }
         var PlcConnectionID=$("#PlcConnectionId").val();
         if(PlcConnectionID==null||PlcConnectionId==""||PlcConnectionId==0)
         {
            popupAlert('请选择PLC连接IP',2,function(data){layer.close(data);});
           return;
         }
        SubmitFormForAjax("/plcwritedb/operateplcwritedbinfo", $("#form-add").serialize(), function (data) {
            if (data.result) {
                    popupAlert('提交成功',1,function(){closePageLayer(true);});
            }else{
                popupAlert(data.message,2,function(data){layer.close(data);});
            }
        },true);
     }
</script>
}